package com.black.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.black.common.annotation.Log;
import com.black.common.core.controller.BaseController;
import com.black.common.core.domain.AjaxResult;
import com.black.common.enums.BusinessType;
import com.black.apartment.domain.ApartmentAttributes;
import com.black.apartment.service.IApartmentAttributesService;
import com.black.common.utils.poi.ExcelUtil;
import com.black.common.core.page.TableDataInfo;

/**
 * 公寓属性信息Controller
 * 
 * @author kuan
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/apartment/apartmentsAttributes")
public class ApartmentAttributesController extends BaseController
{
    @Autowired
    private IApartmentAttributesService apartmentAttributesService;

    /**
     * 查询公寓属性信息列表
     */
    @PreAuthorize("@ss.hasPermi('apartment:apartmentsAttributes:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApartmentAttributes apartmentAttributes)
    {
        startPage();
        List<ApartmentAttributes> list = apartmentAttributesService.selectApartmentAttributesList(apartmentAttributes);
        return getDataTable(list);
    }

    /**
     * 导出公寓属性信息列表
     */
    @PreAuthorize("@ss.hasPermi('apartment:apartmentsAttributes:export')")
    @Log(title = "公寓属性信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApartmentAttributes apartmentAttributes)
    {
        List<ApartmentAttributes> list = apartmentAttributesService.selectApartmentAttributesList(apartmentAttributes);
        ExcelUtil<ApartmentAttributes> util = new ExcelUtil<ApartmentAttributes>(ApartmentAttributes.class);
        util.exportExcel(response, list, "公寓属性信息数据");
    }

    /**
     * 获取公寓属性信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('apartment:apartmentsAttributes:query')")
    @GetMapping(value = "/{attributeId}")
    public AjaxResult getInfo(@PathVariable("attributeId") Long attributeId)
    {
        return success(apartmentAttributesService.selectApartmentAttributesByAttributeId(attributeId));
    }

    /**
     * 新增公寓属性信息
     */
    @PreAuthorize("@ss.hasPermi('apartment:apartmentsAttributes:add')")
    @Log(title = "公寓属性信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApartmentAttributes apartmentAttributes)
    {
        return toAjax(apartmentAttributesService.insertApartmentAttributes(apartmentAttributes));
    }

    /**
     * 修改公寓属性信息
     */
    @PreAuthorize("@ss.hasPermi('apartment:apartmentsAttributes:edit')")
    @Log(title = "公寓属性信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApartmentAttributes apartmentAttributes)
    {
        return toAjax(apartmentAttributesService.updateApartmentAttributes(apartmentAttributes));
    }

    /**
     * 删除公寓属性信息
     */
    @PreAuthorize("@ss.hasPermi('apartment:apartmentsAttributes:remove')")
    @Log(title = "公寓属性信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{attributeIds}")
    public AjaxResult remove(@PathVariable Long[] attributeIds)
    {
        return toAjax(apartmentAttributesService.deleteApartmentAttributesByAttributeIds(attributeIds));
    }
}
